<template>
  <rx-dialog @handOk="onOk" @cancel="cancel">
    <comment ref="current" :is="currentView" :layerid="layerid" :destroy="destroy"></comment>
  </rx-dialog>
</template>

<script>
  import {RxDialog, Util} from "@lowcode/jpaas-common-lib";
  import miniQuerys from '../../../../api/form/core/miniquery';
  export default {
    name: "MiniQuery",
    components: {RxDialog},
    props:["row","fieldDatas","queryAry","showDefault","showRelation","layerid","destroy"],
    data(){
      return {
        currentView:''
      }
    },
    computed:{
      current(){
        return this.$refs.current;
      },
    },
    created() {
      this.currentView=miniQuerys['miniQuery_'+this.row.fc.toLowerCase()];
    },
    mounted(){
      this.setData();
    },
    methods:{
      onOk(e){
        var self=this;
        if(this.current.validate(function(){
          Util.closeWindow(self, "ok");
        }));
        e.loading =false;
      },
      cancel(){
        Util.closeWindow(this,"cancel");
      },
      setData() {
        this.current.setData(this.row,this.fieldDatas,this.queryAry,this.showDefault,this.showRelation);
      },
      getData(){
        return this.current.getData();
      }
    }
  }
</script>

<style scoped>

</style>